Skip to content

Fix duplicate HTLC fail-back on stale force-close #4010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Anyitechs
Copy link
Contributor

This PR addresses the duplicate HTLC fail-back on stale force-close that fail-back one of them and waits till timeout to fail-back everything. This change adds proper tracking of HTLCs by payment hash to ensure all identical HTLCs are failed back immediately when detected, rather than waiting for timeout.

Also introduces a functional test that demonstrates the scenario by creating two identical HTLCs, performing a stale force-close, and verifying both HTLCs are failed back correctly.

Fixes #3570

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Aug 14, 2025

👋 I see @tnull was un-assigned.
If you'd like another reviewer assignment, please click here.

@Anyitechs
Copy link
Contributor Author

This PR is still work in progress. Need some help with the test, I'm able to simulate the scenario described in the issue but the change introduced is triggered when the node restarts and I'm not sure how to simulate that (did a network disconnection and reconnection, but that doesn't seem to do the job).

@tnull tnull self-requested a review August 15, 2025 13:25
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

}
}
if !found_htlc {
// Collecting all outbound HTLC sources into a HashSet allows for efficient,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the ChannelMonitor is the source of the issue here - the issue was about HTLCs being failed back from the on-chain logic in ChannelMonitor (which is responsible for HTLCs once we close a channel) so it should be fixed, not worked around here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you for pointing that out.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@tnull tnull removed their request for review August 20, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add test for duplicate HTLC fail-back
3 participants